Skip to content

Fix/issues 940 941#946

Merged
abuzuhri merged 4 commits into
mainfrom
fix/issues-940-941
Jun 12, 2026
Merged

Fix/issues 940 941#946
abuzuhri merged 4 commits into
mainfrom
fix/issues-940-941

Conversation

@abuzuhri

Copy link
Copy Markdown
Owner

No description provided.

abuzuhri and others added 2 commits June 11, 2026 13:44
Amazon's orders_2026-01-01 model exposes Order.payment (OrderPayment ->
paymentExecutions[] -> PaymentExecution), which was missing from the SDK.

Add OrderPayment and PaymentExecution model classes and wire the Payment
property into Order (DataMember "payment", constructor, ToString/Equals/
GetHashCode), following the existing model conventions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A single RateLimits instance is shared across all concurrent requests of a
given RateLimitType. With no synchronization, parallel calls race on the
token-bucket state: when the bucket is full, each thread advances LastRequest
by ratePeriodMs, so the wait target keeps receding and the limiter never
recovers until the process restarts (the reported "stuck until restart"
symptom). The logic is correct single-threaded; the bug is purely concurrency.

Gate NextRate behind a per-instance SemaphoreSlim (logic moved to NextRateCore).
Each RateLimitType owns its own instance/gate, so distinct endpoints do not
block each other.

Also repair RateLimitsTests, which referenced the rolled-back
WaitForPermittedRequest API and no longer compiled, and add a concurrency
regression test that drives 10 parallel requests and asserts they drain within
a bounded window.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses concurrency issues in the shared rate-limiter implementation and expands the Orders V20260101 model surface to include payment details.

Changes:

  • Serialize RateLimits.NextRate(...) execution with a per-instance SemaphoreSlim to prevent token-bucket state corruption under parallel calls.
  • Update/add NUnit tests to validate expected wait timing and add a regression test for concurrent draining behavior.
  • Add Orders V20260101 payment models (OrderPayment, PaymentExecution) and wire Order.Payment into the Order model.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Source/Tests/RateLimitsTests.cs Updates the rate-limit timing test to use NextRate and adds a parallelism regression test.
Source/FikaAmazonAPI/Utils/RateLimits.cs Adds a semaphore gate to serialize access to shared token-bucket state in NextRate.
Source/FikaAmazonAPI/AmazonSpApiSDK/Models/OrdersV20260101/PaymentExecution.cs Introduces a new model representing a single payment execution.
Source/FikaAmazonAPI/AmazonSpApiSDK/Models/OrdersV20260101/OrderPayment.cs Introduces a new model representing an order’s payment information (list of executions).
Source/FikaAmazonAPI/AmazonSpApiSDK/Models/OrdersV20260101/Order.cs Adds Payment to the Order model, including ctor, equality, string output, and hashing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 45 to 47
/// <param name="rateLimitType">An enum representing the rate limit policy for the resource in use</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns></returns>
Comment thread Source/Tests/RateLimitsTests.cs Outdated
abuzuhri and others added 2 commits June 12, 2026 06:32
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@abuzuhri abuzuhri merged commit b49464f into main Jun 12, 2026
1 check passed
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants